home *** CD-ROM | disk | FTP | other *** search
/ Belgian Amiga Club - ADF Collection / BS1 part 34.zip / BS1 part 34 / Weubblers handler.adf / examples / format40.c < prev    next >
C/C++ Source or Header  |  1989-01-10  |  1KB  |  49 lines

  1. int Drive;
  2. main(argc,argv)
  3. int argc;
  4. char **argv;
  5. {
  6. unsigned short *TrackBuffer;
  7. unsigned char *SectorBuffer;
  8. int List[30];
  9. int drive,track,head;
  10. int numsecs;
  11. char c;
  12. int Error,i;
  13.  
  14. drive=0;
  15. numsecs=10;
  16. while (argc-->1) 
  17. {i=atoi(argv[argc]);
  18.  if (i<4) drive=i;
  19.  else numsecs=i;}
  20.  
  21. printf("WARNING!!! This program will format the disks in drive %d with %d sectors/Track\n",drive,numsecs);
  22. printf("in MSDOS format. IS THIS WHAT YOU REALLY WANT TO DO????\n");
  23. scanf("%c",&c);
  24. if (toupper(c)!='Y') {printf("Poooh... Finishing.\n");_abort();}
  25.  
  26. Drive=drive;
  27. InitMotor();
  28. TrackBuffer=(unsigned short *)AllocChipMem(2*TrackLen);
  29. SectorBuffer=(unsigned char *)AllocNormalMem(512);
  30.  
  31. CreateEmptyStandardTrack(TrackBuffer,0,0,numsecs);
  32. CreateList(TrackBuffer,List);
  33. CreateStandardBootSector(SectorBuffer,40,2,numsecs);
  34. WriteList(TrackBuffer,SectorBuffer,1,List);
  35. ChangeStandardTrack(TrackBuffer,0,0,numsecs);
  36. WriteTrack(TrackBuffer,drive,0,0);
  37. for (i=0;i<512;i++) SectorBuffer[i]=0;
  38. WriteList(TrackBuffer,SectorBuffer,1,List);
  39. for (track=0;track<40;track++)
  40.  for (head=0;head<2;head++)
  41.   if (track|head)
  42.   {
  43.   ChangeStandardTrack(TrackBuffer,track,head,numsecs);
  44.   Error=WriteTrack(TrackBuffer,drive,track,head);
  45.   if (Error) {aprintf(stderr,"Error writing track %d.\n",track);_abort();}
  46.   }
  47. _abort();
  48. }
  49.